<?php
require_once realpath(dirname(__FILE__) . '//..//pages.php');
require_once INC_DEFINES;
require_once INC_FUNCTIONS;
checkSession ();
if (isset ($_SESSION[KEY_SESSION_USER])) {
    require_once CLASS_USER;
    $user = unserialize($_SESSION[KEY_SESSION_USER]);
    $logged = $user->isRegistered ();
} else {
    $logged = false;
}

if ($logged) {
    $msg = '<a href="javascript:history.back();">Torna alla pagina precedente</a>';
} else {
    $msg = '<a href="' . HTTP_CTRL_MAIN . '?account=login&redirect=' . urlencode ($address . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']) . '">Effettua il login</a>';
}

define ('MSG_FAILED_DELETE', 'Failed to delete');
define ('MSG_FAILED_INSERT', 'Failed to insert');
define ('MSG_FAILED_LOGIN', 'Login fallito! ' . '<a href="' . HTTP_CTRL_MAIN . '?account=login">Effettua il login</a>');
define ('MSG_FAILED_LOGOUT', 'Failed to logout!');
define ('MSG_FAILED_REGISTER', 'Failed to register');
define ('MSG_FAILED_SELECT', 'Failed to select');
define ('MSG_FAILED_UPDATE', 'Failed to update');
define ('MSG_SUCCESSFUL_DELETE', 'deleted');
define ('MSG_SUCCESSFUL_INSERT', 'inserted');
define ('MSG_SUCCESSFUL_LOGIN', 'logged in');
define ('MSG_SUCCESSFUL_LOGOUT', 'logged out');
define ('MSG_SUCCESSFUL_REGISTER', 'registered');
define ('MSG_SUCCESSFUL_SELECT', 'selected');
define ('MSG_SUCCESSFUL_UPDATE', 'updated');
define ('MSG_INVALID_REQUEST', 'Invalid request!');
define ('MSG_NOT_AUTHORIZED', 'Non sei autorizzato! ' . $msg);
?>
